IdeaBlade DevForce 2010 Help Reference
ExecuteQueryAsync(IEntityQuery,Action<EntityQueryOperation>,Object) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class > ExecuteQueryAsync Method : ExecuteQueryAsync(IEntityQuery,Action<EntityQueryOperation>,Object) Method



query
The IEntityQuery to execute
userCallback
Callback invoked when the query completes
userState
Token to identify the query upon completion
Execute a query asynchronously.

Syntax

Visual Basic (Declaration) 
Public Overloads Function ExecuteQueryAsync( _
   ByVal query As IEntityQuery, _
   Optional ByVal userCallback As Action(Of EntityQueryOperation), _
   Optional ByVal userState As Object _
) As EntityQueryOperation
Visual Basic (Usage)Copy Code
Dim instance As EntityManager
Dim query As IEntityQuery
Dim userCallback As Action(Of EntityQueryOperation)
Dim userState As Object
Dim value As EntityQueryOperation
 
value = instance.ExecuteQueryAsync(query, userCallback, userState)
C++/CLI 
public:
EntityQueryOperation^ ExecuteQueryAsync( 
   IEntityQuery^ query,
   Action<EntityQueryOperation^>^ userCallback,
   Object^ userState
) 

Parameters

query
The IEntityQuery to execute
userCallback
Callback invoked when the query completes
userState
Token to identify the query upon completion

Exceptions

ExceptionDescription
System.InvalidOperationExceptionDataSource fetch strategies are not allowed when disconnected

Example

C#Copy Code
private void SampleAsynchQuery() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();

  // Build a query and ask mgr to run it asynchronously.
  var query = mgr.Customers.Where(c => c.CompanyName.StartsWith("C"));
  int token = 1;
  mgr.ExecuteQueryAsync(query, AsyncQueryCompleted, token);
}

void AsyncQueryCompleted(EntityQueryOperation<Customer> e) {
  if (e.Error != null) {
    System.Diagnostics.Debug.WriteLine(e.Error.Message);
    return;
  }
  System.Diagnostics.Debug.WriteLine("queryid = " + e.UserState.ToString());
  System.Diagnostics.Debug.WriteLine("customers retrieved = " + e.Results.Count().ToString());
}

Remarks

Provide a userCallback if you want to be notified when the operation completes. The query results will be returned in the EntityQueriedEventArgs passed to the userCallback. Use the userState to uniquely identify this call. You can cancel a pending asynchronous call using CancelAsync.

This feature is only available in certain editions of DevForce.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.